/**
 * 版权所有(C) 晓祥工作室 2010-2020<br>
 * Copyright 2010-2020 XiaoXiang Workroom.<br>
 * 创建日期 2011-11-29
 */
package xx.services.entity.rest;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.core.Context;

import xx.db.sql.Select;
import xx.entity.bas.Category;
import xx.entity.bas.Entity;
import xx.services.Passport;
import xx.services.util.Constants;

public class InitCategoryRest extends Passport
{
    private Entity entity;

    protected Category category;

    public InitCategoryRest(@Context
    HttpServletRequest request)
    {
        super(request);
        entity = new Entity(qr, owner);
        category = new Category(qr, owner);
    }

    @GET
    @Path("/init")
    public String initCategory()
    {
        try
        {
            Select select = new Select(qr, owner);
            select.from(Category.class).where(qr.cnd(Category.PARENT_ID, "=", 0));
            List<Category> list = select.go();
            if (list != null)
            {
//                for (Category c : list)
//                    c.updatePath();
            }
            return ok(true);
        }
        catch (Exception e)
        {
            return error(e);
        }
    }
}
